package cn.wggf.dev.qcgg.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import cn.wggf.dev.qcgg.dao.RecordInterfaceDao;
import cn.wggf.dev.qcgg.pojo.RecordInterface;
import cn.wggf.dev.qcgg.util.SqlService;


/**
 * 接口记录dao接口实现类
 * @author Yubo Jia
 *
 * 2018年1月26日上午9:08:03
 */
public class RecordInterfaceDaoImpl implements RecordInterfaceDao {

	private Logger logger = Logger.getLogger(RecordInterfaceDaoImpl.class);
	
	/**
	 * 添加一条接口记录
	 */
	public int insert(RecordInterface recordInterface) {
		SqlService sqlService = new SqlService();
		Connection con = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		String sql = "insert into qcgg_record_interface (cID, gTime) values(?, ?)";
		Object[] params = new Object[2];
		params[0] = recordInterface.getCid();
		params[1] = recordInterface.getGtime();
		logger.info("执行的sql语句是："+sql);
		int count = 0;
		try {
			con = sqlService.getConnection();
			pstmt = con.prepareStatement(sql);
			pstmt.setObject(1, params[0]);
			pstmt.setObject(2, params[1]);
			count = pstmt.executeUpdate();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e) {
			// TODO: handle exception
		} finally {
			sqlService.close(rs, pstmt, con);
		}
		logger.info("执行的结果为："+count);
		return count;
	}
	
}
